home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / MacPerl5 / pod / perlsub.pod < prev    next >
Encoding:
Text File  |  1994-12-26  |  6.9 KB  |  42 lines  |  [TEXT/MPS ]

  1. mes like "open"
  2. or "chdir" as part of their default @EXPORT list, since these may
  3. sneak into someone else's namespace and change the semantics unexpectedly.
  4. Instead, if the module adds the name to the @EXPORT_OK list, then it's
  5. possible for a user to import the name explicitly, but not implicitly.
  6. That is, they could say
  7.  
  8.     use Module 'open';
  9.  
  10. and it would import the open override, but if they said
  11.  
  12.     use Module;
  13.  
  14. they would get the default imports without the overrides.
  15.  
  16. =head2 Autoloading
  17.  
  18. If you call a subroutine that is undefined, you would ordinarily get an
  19. immediate fatal error complaining that the subroutine doesn't exist.
  20. (Likewise for subroutines being used as methods, when the method
  21. doesn't exist in any of the base classes of the class package.) If,
  22. however, there is an C<AUTOLOAD> subroutine defined in the package or
  23. packages that were searched for the original subroutine, then that
  24. C<AUTOLOAD> subroutine is called with the arguments that would have been
  25. passed to the original subroutine.  The fully qualified name of the
  26. original subroutine magically appears in the $AUTOLOAD variable in the
  27. same package as the C<AUTOLOAD> routine.  The name is not passed as an
  28. ordinary argument because, er, well, just because, that's why...
  29.  
  30. Most C<AUTOLOAD> routines will load in a definition for the subroutine in
  31. question using eval, and then execute that subroutine using a special
  32. form of "goto" that erases the stack frame of the C<AUTOLOAD> routine
  33. without a trace.  (See the standard C<AutoLoader> module, for example.)
  34. But an C<AUTOLOAD> routine can also just emulate the routine and never
  35. define it.  A good example of this is the standard Shell module, which
  36. can treat undefined subroutine calls as calls to Unix programs.
  37.  
  38. There are mechanisms available for modules to help them split themselves
  39. up into autoloadable files to be used with the standard AutoLoader module.
  40. See the document on extensions.
  41.  
  42.